#include "sizetype.h"
QString getFileTypeImg(const QString &suffix){
    if(suffix == "txt"){
        return "txt";
    }else if(suffix.contains("ppt")){
        return "ppt";
    }else if (suffix.contains("pdf")) {
        return "pdf";
    } else if (suffix.contains("doc")) {
        return "doc";
    }else if(suffix.contains("xls")){
        return "xls";
    }else if (suffix.contains("mp3")) {
        return "mp3";
    } else if (suffix.contains("mp4")) {
        return "mp4";
    } else if(suffix.contains("zip")){
        return "zip";
    }
    else{
        return "undefined";
    }
}

QString unitConversion(const qint64 &size){//初始单位为Bytes
    if(size>0){
        int i=0;
        qreal num=size;
        for(;num/1024>1;i++){
            num=num/1024;
        }
        QString type;
        switch (i) {
        case SizeType::Bytes:type=" B";break;
        case SizeType::KB:type=" KB";break;
        case SizeType::MB:type=" MB";break;
        case SizeType::GB:type=" GB";break;
        case SizeType::TB:type=" TB";break;
        }
        return QString::number(round(num * 10.0) / 10.0)+type;
    }
    else
    {
        return QString();
    }
}
